package com.zbkj.service.service;

import com.zbkj.common.model.member.PaidMemberOrder;
import com.zbkj.common.model.order.MonitorOrder;
import com.zbkj.common.model.user.User;
import com.zbkj.common.request.OrderPayRequest;
import com.zbkj.common.request.WechatPaymentQueryRequest;
import com.zbkj.common.response.CashierInfoResponse;
import com.zbkj.common.response.OrderPayResultResponse;
import com.zbkj.common.response.PayConfigResponse;

import java.math.BigDecimal;

/**
 * PayService 接口
 +----------------------------------------------------------------------
 */
public interface PayService {

    /**
     * 获取支付配置
     */
    PayConfigResponse getPayConfig();

    /**
     * 订单支付
     * @param orderPayRequest 订单支付参数
     * @return OrderPayResultResponse
     */
    OrderPayResultResponse payment(OrderPayRequest orderPayRequest);

    /**
     * 查询订单微信支付结果
     * @param orderNo 订单编号
     */
    Boolean queryWechatPayResult(String orderNo);

    /**
     * 查询订单支付宝支付结果
     * @param orderNo 订单编号
     */
    Boolean queryAliPayResult(String orderNo);

    /**
     * 支付成功后置处理(临时)
     * @param orderNo 订单编号
     */
    Boolean payAfterProcessingTemp(String orderNo);

    /**
     * 获取收银台信息
     *
     * @param orderNo 订单号
     */
    CashierInfoResponse getCashierIno(String orderNo);

    /**
     * 购买分配佣金给上级
     * @param order
     * @return
     */
    boolean assignCommissionVip(PaidMemberOrder order);
    /**
     * 入驻分销流量充值佣金处理
     * vipMemberId vip会员id
     * uId 支付用户id
     * @return 佣金记录列表
     */
    boolean joiningDistribution(MonitorOrder monitorOrder);

    /**
     * 查询微信支付结果
     */
    Boolean queryWechatPaymentResult(WechatPaymentQueryRequest request);

    /**
     * 扣减用户余额
     * @param uid
     * @param orderNo
     * @param canUseBalance
     */
    void subUserBalance(Integer uid, String orderNo, BigDecimal canUseBalance);

    BigDecimal getCanUseBalance(User user, Boolean useBalance);

    void redoUserBalance(Integer uid, String orderNo, BigDecimal canUseBalance, int i);

    /**
     * 退还余额
     * @param uid
     * @param orderNo
     * @param canUseBalance
     */
    void subUserBalanceByOrderCancel(Integer uid, String orderNo, BigDecimal canUseBalance);
}
